package com.cn.xiaonuo.slbfinances.sladapays.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cn.xiaonuo.common.entity.BusinessMessage;
import com.cn.xiaonuo.dbs.core.annotation.DataSource;
import com.cn.xiaonuo.slbfinances.sladapays.mapper.CmAdapayWalletMapper;
import com.cn.xiaonuo.slbfinances.sladapays.service.IAdapayWalletService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AdapayWalletServiceImpl extends ServiceImpl<CmAdapayWalletMapper,String> implements IAdapayWalletService {

    @Autowired
    private CmAdapayWalletMapper cmAdapayWalletMapper;

    @Override
    @DataSource(name = "jyb_soole_data_hn")
    public BusinessMessage queryWalletList(Integer pageNum, Integer pageSize, Integer slUserId) throws Exception {
        BusinessMessage<Object> message = new BusinessMessage<>();
        if (null == pageNum || pageNum <= 1) {
            pageNum = 1;
        }
        if (null == pageSize || pageSize <= 1) {
            pageSize = 10;
        }
        // 设置分页参数
        PageHelper.startPage(pageNum, pageSize);
        List<Map<String, Object>> list = cmAdapayWalletMapper.queryWalletList(slUserId);
        PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(list);
        if(null!=list && list.size()>=0){
            message.setData(pageInfo);
            message.setSuccess(true);
            message.setCode("200");
            message.setMessage("查询汇付天下钱包信息成功");
            return message;
        }
        message.setSuccess(false);
        message.setCode("-1");
        message.setMessage("查询汇付天下钱包信息失败");
        return message;
    }
}
